from zz import zz_sys_proxy, zz_str
import sys


def main():
    arg = sys.argv[1:]
    if len(arg) == 0:
        print("缺少重置参数")
        print("usage:   set_proxy.py command ip:port")
        print("example: set_proxy.py 1 192.168.0.100:8080")
        return

    set = arg[0]  # 【1】开始代理；【0】关闭代理
    ip = ''  # ip + 端口
    if len(arg) > 1:
        ip = arg[1]
    if set == '1' and zz_str.is_null_or_empty(ip):
        print("miss ip:ports")
        return

    if set == '1':
        zz_sys_proxy.set_sys_proxy(ip)
        print("代理开启成功")
    else:
        zz_sys_proxy.close_sys_proxy()
        print("代理关闭成功")


if __name__ == '__main__':
    main()
    # zz_sys_proxy.set_sys_proxy('192.168.0.193:8181')
    # zz_sys_proxy.close_sys_proxy()
    pass
